//
//  GAKKIBaseWebViewController.h
//  GANGAIKit
//
//  Created by fh on 2019/11/15.
//  Copyright © 2019 cashchina. All rights reserved.
//

#import "GAKKIBaseViewController.h"
#import <WebKit/WebKit.h>

NS_ASSUME_NONNULL_BEGIN

/// webView控制器基类
@interface GAKKIBaseWebViewController : GAKKIBaseViewController <WKNavigationDelegate,WKUIDelegate,WKScriptMessageHandler>
/** webView */
@property (nonatomic, readonly, strong) WKWebView *webView;
/** messageHandlers: 就是你要注册的 JS 调用 OC 的方法名 */
@property (nonatomic, readwrite, copy) NSArray <NSString *> *messageHandlers;

/** 是否取消导航栏的title等于webView的title。默认是不取消，default is YES */
@property (nonatomic, readwrite, assign) BOOL shouldDisableWebViewTitle;
/** 是否取消关闭按钮。默认是不取消，default is NO */
@property (nonatomic, readwrite, assign) BOOL shouldDisableWebViewClose;

/** web url quest 如果localFile == YES , 则requ
 estUrl 为本地路径 ； 反之，requestUrl为远程url str */
@property (nonatomic, readwrite, copy) NSString *requestUrl;
/** 是否是本地文件 default is NO */
@property (nonatomic, readwrite, assign, getter = isLocalFile) BOOL localFile;
/** 是否自动加载URL default is YES */
@property (nonatomic, readwrite, assign) BOOL shouldAutoLoadRequestUrl;

/// 创建对象
+ (instancetype)new;

/// 初始化
- (instancetype)init;

/// 用传递参数初始化
/// @param params 传递参数
- (instancetype)initWithParams:(NSDictionary * __nullable)params;

/**
 手动调用加载:viewDidLoad.属性shouldAutoLoadRequestUrl为NO是需要手动调用该方法加载URL
 */
- (void)loadRequestUrl;

/** 导航栏高度 默认是 系统导航栏的高度 */
@property (nonatomic, readwrite, assign) CGFloat navigationBarHeight;
/** 内容缩进 (64,0,0,0) */
@property (nonatomic, readonly, assign) UIEdgeInsets contentInset;

/** 子类重写,不能手动调用:如果要自定义webView的布局需要子类重写 */
- (void)layoutWebViewFrame;

@end

NS_ASSUME_NONNULL_END
